package com.jumper.property.comparer.core.formatter;


import com.jumper.property.comparer.core.constant.FormatConstant;

import java.util.List;

public class CombinationDiffFormatter extends AbstractDiffFormatter {

    private final String propertyName;
    private final List<String> beforeValues;
    private final List<String> afterValues;

    public CombinationDiffFormatter(String propertyName, List<String> beforeValues, List<String> afterValues) {
        this.propertyName = propertyName;
        this.beforeValues = beforeValues;
        this.afterValues = afterValues;
    }

    @Override
    public String format() {
        return pattern.getCombinationDiffPattern()
                .replace(FormatConstant.DISPLAY_PROPERTY_KEY, propertyName)
                .replace(FormatConstant.BEFORE_VALUE_KEY, String.join(pattern.getCombinationJoinDiffPattern(), beforeValues))
                .replace(FormatConstant.AFTER_VALUE_KEY, String.join(pattern.getCombinationJoinDiffPattern(), afterValues));
    }
}
